package com.ruoyi.web.controller.admin;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BdmTopupRecord;
import com.ruoyi.system.domain.dto.BdmTopupRecordDto;
import com.ruoyi.system.domain.vo.BdmTopupRecordVo;
import com.ruoyi.system.service.IBdmTopupRecordService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 提现记录Controller
 *
 * @author ruoyi
 * @date 2024-12-20
 */
@Api(tags = "后台-提现记录")
@RestController
@RequestMapping("/system/record")
public class BdmTopupRecordController extends BaseController
{
    @Autowired
    private IBdmTopupRecordService bdmTopupRecordService;

    /**
     * 查询提现记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmTopupRecord bdmTopupRecord)
    {
        startPage();
        List<BdmTopupRecord> list = bdmTopupRecordService.selectBdmTopupRecordList(bdmTopupRecord);
        return getDataTable(list);
    }

    /**
     * 导出提现记录列表
     */
    @Log(title = "提现记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BdmTopupRecord bdmTopupRecord)
    {
        List<BdmTopupRecordVo> list = bdmTopupRecordService.export(bdmTopupRecord);
        ExcelUtil<BdmTopupRecordVo> util = new ExcelUtil<BdmTopupRecordVo>(BdmTopupRecordVo.class);
        util.exportExcel(response, list, "提现记录数据");
    }

    /**
     * 获取提现记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bdmTopupRecordService.selectBdmTopupRecordById(id));
    }

    /**
     * 修改提现记录
     */
    @Log(title = "提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BdmTopupRecord bdmTopupRecord)
    {
        return toAjax(bdmTopupRecordService.updateBdmTopupRecord(bdmTopupRecord));
    }

    /**
     * 提现审核通过
     */
    @Log(title = "提现审核通过", businessType = BusinessType.UPDATE)
    @PostMapping("/pass")
    public AjaxResult pass(@RequestBody BdmTopupRecordDto dto)
    {
        return success(bdmTopupRecordService.passNew(dto.getIds()));
    }

    /**
     * 提现审核驳回
     */
    @Log(title = "提现审核驳回", businessType = BusinessType.UPDATE)
    @PostMapping("/reject")
    public AjaxResult reject(@RequestBody BdmTopupRecordDto dto)
    {
        return toAjax(bdmTopupRecordService.rejectNew(dto.getIds()));
    }

    /**
     * 已打款
     */
    @Log(title = "已打款", businessType = BusinessType.UPDATE)
    @PostMapping("/remittance")
    public AjaxResult remittance(@RequestBody BdmTopupRecordDto dto)
    {
        return toAjax(bdmTopupRecordService.remittance(dto.getIds()));
    }

    /**
     * 异常
     */
    @Log(title = "异常", businessType = BusinessType.UPDATE)
    @PostMapping("/error")
    public AjaxResult error(@RequestBody BdmTopupRecordDto dto)
    {
        return toAjax(bdmTopupRecordService.error(dto.getIds()));
    }


    /**
     * 删除提现记录
     */
    @Log(title = "提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bdmTopupRecordService.deleteBdmTopupRecordByIds(ids));
    }

    /**
     * 提现审核统计
     * @return
     */
    @GetMapping("/withdrawStatistics")
    public AjaxResult withdrawStatistics()
    {
        return success(bdmTopupRecordService.withdrawStatistics());
    }
}
